﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _30让ComboBox控件添加图标
{


    /// <summary>
    /// UCImage.xaml 的交互逻辑
    /// </summary>
    public partial class UCImage : UserControl
    {
        ImageInfoClass iic = new ImageInfoClass();

        public UCImage()
        {
            InitializeComponent();
            this.Loaded += UCImage_Loaded;
        }

        public UCImage(string imagePath, string text)
            :this()
        {
            iic.ImagePath = imagePath;
            iic.Text = text;

            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(iic.Text, UriKind.Relative);
            bi.EndInit();
            this.myImage.Stretch = Stretch.Fill;
            this.myImage.Source = bi;

            this.laText.Content = iic.Text;
        }

        private void UCImage_Loaded(object sender, RoutedEventArgs e)
        {
            
        }
    }
}
